/*
 * $Id: qtcQTableWidget.cpp 10 2010-11-09 01:11:36Z tfonrouge $
 */

#include "qtharbour.h"

#include <QTableWidget>
#include <QStandardItem>

HB_FUNC( QTABLEWIDGET_NEW )
{
    xho_ObjParams objParams = xho_ObjParams( NULL );
    
    QPointer<QTableWidget> tableWidget = NULL;

    if( hb_pcount() > 0 )
    {
        tableWidget = new QTableWidget( hb_parni( 1 ), hb_parni( 2 ), (QWidget *) xho_par_XhoObject( 3, "QWidget" ) );
    }
    else
    {
        tableWidget = new QTableWidget( (QWidget *) xho_par_XhoObject( 1, "QWidget" ) );
    }

    objParams.Return( tableWidget );
}

/* <QTH_GEN> */
HB_FUNC( QTABLEWIDGET_CELLWIDGET )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        xho_itemReturn( (QWidget *) tableWidget->cellWidget( hb_parni( 1 ), hb_parni( 2 ) ) );
    }
}

HB_FUNC( QTABLEWIDGET_COLUMN )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->column( (QTableWidgetItem *) xho_par_XhoObject( 1 ) ) + 1 );
    }
}

HB_FUNC( QTABLEWIDGET_COLUMNCOUNT )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->columnCount() );
    }
}

HB_FUNC( QTABLEWIDGET_CURRENTCOLUMN )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->currentColumn() + 1 );
    }
}

HB_FUNC( QTABLEWIDGET_CURRENTITEM )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        tableWidget->currentItem();
    }
}

HB_FUNC( QTABLEWIDGET_CURRENTROW )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->currentRow() + 1 );
    }
}

HB_FUNC( QTABLEWIDGET_EDITITEM )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        tableWidget->editItem( (QTableWidgetItem *) xho_par_XhoObject( 1 ) );
    }
}

HB_FUNC( QTABLEWIDGET_ITEM )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        xho_itemReturn( (QObject *) tableWidget->item( hb_parni( 1 ) - 1, hb_parni( 2 ) - 1 ) );
    }
}

HB_FUNC( QTABLEWIDGET_ROW )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->row( (QTableWidgetItem *) xho_par_XhoObject( 1 ) ) + 1 );
    }
}

HB_FUNC( QTABLEWIDGET_ROWCOUNT )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        hb_retni( tableWidget->rowCount() );
    }
}

HB_FUNC( QTABLEWIDGET_SETITEM )
{
    QTableWidget* tableWidget = (QTableWidget *) xho_itemListGet_XHO( hb_stackSelfItem() );

    if( tableWidget )
    {
        tableWidget->setItem( hb_parni( 1 ) - 1, hb_parni( 2 ) - 1, (QTableWidgetItem *) xho_par_XhoObject( 3 ) );
    }
}

/* </QTH_GEN> */
